
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administracion</title>

<link rel="stylesheet" type="text/css"  href="css/admin.css"/>
</head>


<body>
<div>
<h1>Galeria</h1>
<h2>Listado de galerias</h2>
<?php
$folder = $_POST["folder"];

echo "$folder<br />";

$allowedExts = array("jpg", "jpeg", "gif", "png");
$fileName = $_FILES["file"]["name"];

$value = explode(".", $fileName);
$extension = end($value);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 150000)
&& in_array($extension, $allowedExts))
{
	if ($_FILES["file"]["error"] > 0)
	{
		echo "<div id=\"informacion\">Return Code: " . $_FILES["file"]["error"] . "</div>";
	}
	else
	{		
		if (file_exists($folder."/". $_FILES["file"]["name"]))
		{
			echo "<div id=\"informacion\"><strong>". $_FILES["file"]["name"] . " already exists. </strong></div>";
		}
		else
		{
			
			echo "<div id=\"informacion\">";
			echo "Image  : " . $_FILES["file"]["name"] . "<br />";
			echo "Tipo	 : " . $_FILES["file"]["type"] . "<br />";
			echo "Tamaño : " . ($_FILES["file"]["size"] / 1024) . " Kb <br />";
			/*echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";*/

			move_uploaded_file($_FILES["file"]["tmp_name"], $folder."/" . $_FILES["file"]["name"]);
			echo "Guardada en : " . $folder ."/". $_FILES["file"]["name"];
			echo "</div>";
			
			echo "<br /><br />";
			echo "<div> <img src=\"". $folder ."/". $_FILES["file"]["name"]."\"/> </div>";
		}
		
	}
}
else
{
	echo "<div id=\"informacion\">Invalid file</div>";
}

echo "<div><strong><a href=\"listar-imagenes.php?dir=".$folder ."\">Atras</a></strong></div>"
?>
</div>
</body>
</html>